<?php
// +----------------------------------------------------------------------
// | Created by PHPstorm: [ JRK丶Admin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/6/26 0026
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------

namespace app\admin\controller;


use app\common\controller\AdminBaseController;
use app\common\model\tang\CostName;
use app\common\model\tang\CostRule;
use app\common\model\tang\Merchant as MerchantModel;
use app\common\model\tang\Cost as CostModel;
use app\common\model\tang\CostType;
use app\common\model\tang\ReleaseUser;
use app\common\model\tang\StaffRule;
use app\common\model\tang\SubjectList;
use think\facade\Config;
use think\facade\Db;

class CostAudit extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->model = new CostModel();
    }

    public function index()
    {
        if (IS_AJAX){
            return $this->model->getAdminPageData($this->param, 'id desc', ['pay_status' => -2]);
//            return $this->model->getAdminPageData($this->param, 'id desc',[]);
        }
        $merchant_list =getMerchant();
        //获取菜单列表
        $this->assign(compact("merchant_list"));
        return $this->fetch();
    }

    public function audit(){
        $ids = $this->request->param();
        $update = (new \app\common\model\tang\Cost())->whereIn('id',$ids)->update(['pay_status'=>0]);
        if($update){
            return self::ajaxResult([],0,1,'审核成功');
        }else{
            return self::ajaxResult([],0,0,'审核失败');
        }
    }
    public function auditall(){
        $ids = $this->request->param();
        $update = (new \app\common\model\tang\Cost())->where('pay_status',-2)->update(['pay_status'=>0]);
        if($update){
            return self::ajaxResult([],0,1,'审核成功');
        }else{
            return self::ajaxResult([],0,0,'审核失败');
        }
    }
}